﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Microsoft.ResourceManagement.ObjectModel.ResourceTypes
{
    public class RmPerson : RmResource
    {
        public RmPerson()
            : base()
        {

        }
        RmList<RmReference> authNWorkflowsRegistered;

        protected const String ResourceType = @"Person";

        protected override void EnsureAllAttributesExist()
        {
            base.EnsureAllAttributesExist();

            base.EnsureAttributeExists(AttributeNames.AccountName);
            base.EnsureAttributeExists(AttributeNames.Domain);
            base.EnsureAttributeExists(AttributeNames.DomainConfiguration);
            base.EnsureAttributeExists(AttributeNames.Email);
            base.EnsureAttributeExists(AttributeNames.EmployeeID);
            base.EnsureAttributeExists(AttributeNames.EmployeeType);
            base.EnsureAttributeExists(AttributeNames.FirstName);
            base.EnsureAttributeExists(AttributeNames.LastName);
            base.EnsureAttributeExists(AttributeNames.MailNickname);
            base.EnsureAttributeExists(AttributeNames.Manager);
            base.EnsureAttributeExists(AttributeNames.ObjectSID);
            base.EnsureAttributeExists(AttributeNames.Register);
            base.EnsureAttributeExists(AttributeNames.RegistrationRequired);
            base.EnsureAttributeExists(AttributeNames.AuthNWorkflowsRegistered);
            base.EnsureAttributeExists(AttributeNames.ResetPassword);
        }

        public override string GetResourceType()
        {
            return RmPerson.ResourceType;
        }

        #region promoted properties

        public RmReference Manager
        {
            get
            {
                return GetReference(AttributeNames.Manager);
            }
            set
            {
                base[AttributeNames.Manager].Value = value;
            }
        }

        public String FirstName
        {
            get
            {
                return GetString(AttributeNames.FirstName); 
            }
            set
            {
                base[AttributeNames.FirstName].Value = value;
            }
        }

        public String LastName
        {
            get
            {
                return GetString(AttributeNames.LastName);
            }
            set
            {
                base[AttributeNames.LastName].Value = value;
            }
        }

        public String Email
        {
            get
            {
                return GetString(AttributeNames.Email);
            }
            set
            {
                base[AttributeNames.Email].Value = value;
            }
        }

        public String Domain
        {
            get
            {
                return GetString(AttributeNames.Domain);
            }
            set
            {
                base[AttributeNames.Domain].Value = value;
            }
        }

        public String AccountName
        {
            get
            {
                return GetString(AttributeNames.AccountName);
            }
            set
            {
                base[AttributeNames.AccountName].Value = value;
            }
        }

        public String MailNickname
        {
            get
            {
                return GetString(AttributeNames.MailNickname);
            }
            set
            {
                base[AttributeNames.MailNickname].Value = value;
            }
        }

        public String EmployeeID
        {
            get
            {
                return GetString(AttributeNames.EmployeeID);
            }
            set
            {
                base[AttributeNames.EmployeeID].Value = value;
            }
        }

        public String EmployeeType
        {
            get
            {
                return GetString(AttributeNames.EmployeeType);
            }
            set
            {
                base[AttributeNames.EmployeeType].Value = value;
            }
        }

        public IList<RmReference> AuthNWorkflowsRegistered
        {
            get
            {
                if (this.authNWorkflowsRegistered == null)
                {
                    lock (base.attributes)
                    {
                        this.authNWorkflowsRegistered = GetMultiValuedReference(AttributeNames.AuthNWorkflowsRegistered);
                        return this.authNWorkflowsRegistered;
                    }
                }
                else
                {
                    return this.authNWorkflowsRegistered;
                }
            }
        }

        public bool ResetPassword
        {
            get
            {
                return GetBoolean(AttributeNames.ResetPassword);
            }
            set
            {
                base[AttributeNames.ResetPassword].Value = value;
            }
        }

        

        #endregion

        public sealed new class AttributeNames
        {
            public static RmAttributeName AccountName = new RmAttributeName(@"AccountName");
            public static RmAttributeName Domain = new RmAttributeName(@"Domain");
            public static RmAttributeName DomainConfiguration = new RmAttributeName(@"DomainConfiguration");
            public static RmAttributeName EmployeeType = new RmAttributeName(@"EmployeeType");
            public static RmAttributeName EmployeeID = new RmAttributeName(@"EmployeeID");
            public static RmAttributeName Email = new RmAttributeName(@"Email");
            public static RmAttributeName FirstName = new RmAttributeName(@"FirstName");
            public static RmAttributeName LastName = new RmAttributeName(@"LastName");
            public static RmAttributeName MailNickname = new RmAttributeName(@"MailNickname");
            public static RmAttributeName Manager = new RmAttributeName(@"Manager");
            public static RmAttributeName ObjectSID = new RmAttributeName(@"ObjectSID");
            public static RmAttributeName Register = new RmAttributeName(@"Register");
            public static RmAttributeName RegistrationRequired = new RmAttributeName(@"RegistrationRequired");
            public static RmAttributeName AuthNWorkflowsRegistered = new RmAttributeName(@"AuthNWFRegistered");
            public static RmAttributeName ResetPassword = new RmAttributeName(@"ResetPassword");
            
        }
    }
}
